package com.gsm.controller;

import com.gsm.entity.CourseDetails;
import com.gsm.service.CourseDetailsService;
import com.gsm.entity.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 课程细节(CourseDetails)表控制层
 *
 * @author wjq
 * @since 2020-05-01 18:57:05
 */
@RestController
@RequestMapping("courseDetails")
public class CourseDetailsController {
    @Autowired
    private CourseDetailsService courseDetailsService;
    
    /**
     * 新增
     */
    @PostMapping("courseDetails")
    public Result insertCourseDetails(@RequestBody CourseDetails courseDetails) {
        Result result = courseDetailsService.insertCourseDetails(courseDetails);
        return result;
    }
    
    /**
     * 根据 id 删除数据
     */
    @DeleteMapping("courseDetails/{courseDetailsId}")
    public Result deleteCourseDetailsByCourseDetailsId(@PathVariable("courseDetailsId")Long courseDetailsId) {
        Result result = courseDetailsService.deleteCourseDetailsByCourseDetailsId(courseDetailsId);
        return result;
    }

    /**
     * 根据 id 修改单条数据
     */
    @PutMapping("courseDetails/{courseDetailsId}")
    public Result updateCourseDetailsByCourseDetailsId(@PathVariable("courseDetailsId")Long courseDetailsId, @RequestBody CourseDetails courseDetails) {
        courseDetails.setCourseDetailsId(courseDetailsId);
        Result result = courseDetailsService.updateCourseDetailsByCourseDetailsId(courseDetails);
        return result;
    }

    /**
     * 根据 id 查询单条数据
     */
    @GetMapping("courseDetails/{courseDetailsId}")
    public Result selectCourseDetailsByCourseDetailsId(@PathVariable("courseDetailsId")Long courseDetailsId) {
        Result result = courseDetailsService.selectCourseDetailsByCourseDetailsId(courseDetailsId);
        return result;
    }
    
    /**
     * 根据条件查询 List
     */
    @GetMapping("courseDetailsList")
    public Result selectCourseDetailsList(CourseDetails courseDetails) {
        Result result = courseDetailsService.selectCourseDetailsList(courseDetails);
        return result;
    }
}